# ORM基类定义模块
# 该文件定义了所有数据库模型的基类，包含通用字段和方法

from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
from datetime import datetime
from typing import Optional

class Base(DeclarativeBase):
    """
    SQLAlchemy ORM基类，所有模型都将继承此类
    """
    pass

class BaseModelMixin:
    """
    模型混入类，提供通用字段
    """
    id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
    created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow)
    updated_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, onupdate=datetime.utcnow)
    is_active: Mapped[bool] = mapped_column(default=True)